﻿using System;
using System.Linq;
using System.Linq.Expressions;
using OutDbContext;
using User.Api.Helpers;

namespace User.Api.BizExtensions
{
    public static class ApptOrderExtensions
    {
        public static IQueryable<ApptOrder> IsStatus(this IQueryable<ApptOrder> source,
            params OrderStatus[] orderStatuses)
        {
            if (orderStatuses.Length <= 0)
            {
                return source;
            }

            var intOrderStatus = (int)orderStatuses[0];
            Expression<Func<ApptOrder, bool>> expression = x => x.OrderStatus == intOrderStatus;

            for (int i = 1; i < orderStatuses.Length; i++)
            {
                var intOrderStatus2 = (int)orderStatuses[i];
                var expressionHelper = new ExpressionHelper<ApptOrder>();
                expression = expressionHelper.BuildQueryOr(expression, x => x.OrderStatus == intOrderStatus2);
            }

            return source.Where(expression);
        }

     
        // 0未锁号 1锁号中 2锁号失败 3已锁号 4取消锁号中 5取消锁号成功 6取消锁号失败 
        // 7预约中 8预约成功 9预约失败 10取消预约中 11取消预约成功 12取消预约失败 
        // 13支付中 14支付失败 15支付成功 16取号中 17取号失败 18退款中 19退款成功 20退款失败 21取号成功 
        // 22微信退号中 23微信退号失败 24微信退号成功 25微信退号退款中 26微信退号退款失败 27微信退号退款成功 
        // 28窗口退号微信退款中 29 窗口退号微信退款成功 30 窗口退号微信退款失败
        public enum OrderStatus
        {
            未锁号 = 0,
            锁号中 = 1,
            锁号失败 = 2,
            锁号成功 = 3,
            取消锁号中 = 4,
            取消锁号成功 = 5,
            取消锁号失败 = 6,
            预约中 = 7,
            预约成功 = 8,
            预约失败 = 9,
            取消预约中 = 10,
            取消预约成功 = 11,
            取消预约失败 = 12,
            支付中 = 13,
            支付失败 = 14,
            支付成功 = 15,
            取号中 = 16,
            取号失败 = 17,
            退款中 = 18,
            退款成功 = 19,
            退款失败 = 20,
            取号成功 = 21,
            预约报到失败 = 22,
            预约报到成功 = 23,
            预约报到中 = 24,
            微信退号中 = 25,
            微信退号失败 = 26,
            微信退号成功 = 27,
            微信退号退款中 = 28,
            微信退号退款失败 = 29,
            微信退号退款成功 = 30
        }

        public enum OrderType
        {
            预约 = 0,
            其它平台预约 = 1,
            直接挂号 = 2
        }

        /// <summary>
        /// 支付状态:0-未付款,1-已付款,2-退款中,3-已退款,4-退款失败
        /// </summary>
        public enum PayState
        {
            未付款 = 0,
            已付款 = 1,
            退款中 = 2,
            已退款 = 3,
            退款失败 = 4
        }
    }
}